package com.easy;

import java.util.Stack;

/**
 * Created by Lxk on 2020/2/10.
 */
class MyQueue {

    private Stack<Integer> stack = null;

    private Stack<Integer> helpStack = null;

    /**
     * Initialize your data structure here.
     */
    public MyQueue() {
        stack = new Stack<>();
        helpStack = new Stack<>();
    }

    /**
     * Push element x to the back of queue.
     */
    public void push(int x) {
        helpStack.push(x);
    }

    /**
     * Removes the element from in front of queue and returns that element.
     */
    public int pop() {
        if (stack.isEmpty()) {
            while (!helpStack.isEmpty()) {
                stack.push(helpStack.pop());
            }
        }
        return stack.pop();
    }

    /**
     * Get the front element.
     */
    public int peek() {
        if (stack.isEmpty()) {
            while (!helpStack.isEmpty()) {
                stack.push(helpStack.pop());
            }
        }
        return stack.peek();
    }

    /**
     * Returns whether the queue is empty.
     */
    public boolean empty() {
        return stack.isEmpty() && helpStack.isEmpty();
    }

}

public class Solution232 {

    public static void main(String[] args) {
        MyQueue queue = new MyQueue();
        queue.push(1);
        queue.push(2);
        System.out.println(queue.peek());
        System.out.println(queue.pop());
        System.out.println(queue.empty());
    }

}
